package com.dev.security.manager.beans;

import java.util.Map;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.dev.security.login.beans.LoginSource;

/**
 * 应用，包含多个权限
 * @author 潜行的青衣
 * @see
 */
@Entity
@Table(name = "t_cds_app")
public class App implements LoginSource {

	@Id
	@Column(name = "id", length = 50, unique = true, nullable = false)
	private String id;
	
	@Column(name = "name", length = 20, nullable = false)
	private String name;
	
	@Column(name = "uri", length = 200, unique = true, nullable = false)
	private String uri;
	
	@Column(name = "icon", length = 200, nullable = false)
	private String icon;
	
	@Column(name = "folder", length = 200)
	private String folder;
	
	@Column(name = "desktop", length = 1)
	private boolean desktop = true;
	
	@Column(name = "order_index")
	private int index;
	
	@Transient
	private Map<String, Boolean> perms;

	public App() {}
	
	public App(String id) {
		this.id = id;
	}
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUri() {
		return uri;
	}

	public void setUri(String uri) {
		this.uri = uri;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}

	public String getFolder() {
		return folder;
	}

	public void setFolder(String folder) {
		this.folder = folder;
	}

	public boolean isDesktop() {
		return desktop;
	}

	public void setDesktop(boolean desktop) {
		this.desktop = desktop;
	}

	public Map<String, Boolean> getPerms() {
		return perms;
	}

	public void setPerms(Map<String, Boolean> perms) {
		this.perms = perms;
	}

	/* (non-Javadoc)
	 * @see com.dev.security.login.beans.LoginSource#getType()
	 */
	@Transient
	@Override
	public String getType() {
		return this.getId();
	}
	
}
